<?php

class BaseAction extends Action{

	protected  $cityid;

	protected  $cityname;

	protected  $cateid; 

	protected  $cityinfo;

	protected  $uinfo;

	function __construct(){

		parent::__construct();
        if(!isMobile()){
            header("location:http://www.yeczx.com");
            exit();
        }

		 $data = array('top'=>'0','toptime'=>'0');
		 $nowtime = mktime();	//得到现在时间
		 M('Zhaopin')->where('status=1 and top>0 and toptime<'.mktime())->setField($data);  //超时下架
		
		
        $city = $_COOKIE['ddcitypinyinClient'];//从COOKEID里找到城市

		  if(isset($_GET['city'])){    //如果存在城市
				$city = $_GET['city'];
		 }  
		 
		 



		$cid = $_GET['cid'];

		$cityinfo = M('City')->where("pinyin='".$city."'")->find();

		//搜索
		
		if(isset($_POST['search'])){
		$data['input_keywords']=$_POST['input_keywords'];
		header("Location: ".U('Search/index',array('keywords'=>$data['input_keywords'])));
		}
	
		

		if(S('citylist')){
            $citylist = S('citylist');
            
        }else{
            $Data=M('City');
            
            $temp=$Data->where('cid=0 AND status=0')->select();
            
            foreach ($temp as $v){
            
                $v['city'] = M('City')->where("cid=".$v['id']." AND status=0")->select();
            
                $citylist[]=$v;
            
            }
            S("citylist",$citylist,360); 
        }

		$this->assign('citylist',$citylist);

		//判断登录



		$this->cityinfo = $cityinfo;

		$this->cityid = $cityinfo['id'];
	
		if(empty($cid)){

		  $this->cateid =0;	

		}else{

		  $this->cateid = M('Category')->where("path='".$cid."'")->getField("id");

		}

		$this->assign("cateid",$this->cateid);

		$cate = M('Category')->select();

	    $config = M('Config')->where("id=1")->find();

	    $this->assign("config",$config);

		$this->assign("cate",$cate);

		$this->assign("city",$city);//城市目录

		$this->assign("cityname",$cityinfo['city']);



	}



}

?>